package com.moc.web.controller.system;

import com.moc.common.annotation.Log;
import com.moc.common.core.controller.BaseController;
import com.moc.common.core.domain.AjaxResult;
import com.moc.common.core.domain.entity.SysMinioFile;
import com.moc.common.core.page.TableDataInfo;
import com.moc.common.enums.BusinessType;
import com.moc.common.utils.poi.ExcelUtil;
import com.moc.system.service.ISysMinioFileService;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * MinIO文件存储Controller
 *
 * @author wangbf
 * @date 2025-09-16
 */
@RestController
@RequestMapping("/system/minioFile")
public class SysMinioFileController extends BaseController
{
    @Autowired
    private ISysMinioFileService sysMinioFileService;

    /**
     * 查询MinIO文件存储列表
     */
    @PreAuthorize("@ss.hasPermi('system:minio:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysMinioFile sysMinioFile)
    {
        startPage();
        List<SysMinioFile> list = sysMinioFileService.selectSysMinioFileList(sysMinioFile);
        return getDataTable(list);
    }

    /**
     * 获取MinIO文件存储详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:minio:query')")
    @GetMapping(value = "getMinioFile/{id}")
    public AjaxResult getMinioFile(@PathVariable("id") Long id)
    {
        return success(sysMinioFileService.selectSysMinioFileById(id));
    }

    /**
     * 删除MinIO文件存储
     */
    @PreAuthorize("@ss.hasPermi('system:minio:remove')")
    @Log(title = "MinIO文件存储", businessType = BusinessType.DELETE)
	@DeleteMapping("/removeMinioFile/{ids}")
    public AjaxResult removeMinioFile(@PathVariable Long[] ids)
    {
        return toAjax(sysMinioFileService.removeMinioFileByIds(ids));
    }
}
